home *** CD-ROM | disk | FTP | other *** search
- {************************************************}
- { A Demo Program to load Icons onto the Screen }
- { }
- {************************************************}
-
- program MyProgram;
-
- uses WinTypes, WinProcs, WObjects;
- {$R bitmaps.res}
-
- type
- TMyApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- TYPE
- MyLong = RECORD
- CASE Integer OF
- 0: (TheLong:LongInt);
- 1: (Lo: Word;
- Hi: Word);
- END;
-
- type
- PMyWindow = ^TMyWindow;
- TMyWindow = object(TWindow)
- PROCEDURE MakeBrush(Var Msg:TMessage);Virtual;
- Constructor Init(AParent : PwindowsObject; Atitle: PChar);
- function CanClose: Boolean; virtual;
- procedure WMLButtonDown(var Msg: TMessage);
- virtual wm_First + wm_LButtonDown;
- procedure WMRButtonDown(var Msg: TMessage);
- virtual wm_First + wm_RButtonDown;
- end;
-
- {--------------------------------------------------}
- { TMyWindow's method implementations: }
- {--------------------------------------------------}
-
- function TMyWindow.CanClose: Boolean;
- var
- Reply: Integer;
- begin
- CanClose := True;
- end;
-
- procedure TMyWindow.WMLButtonDown(var Msg: TMessage);
- begin
- MessageBox(HWindow, 'You have pressed the left mouse button',
- 'Message Dispatched', mb_Ok);
- end;
-
- procedure TMyWindow.WMRButtonDown(var Msg: TMessage);
- begin
- MessageBox(HWindow, 'You have pressed the right mouse button',
- 'Message Dispatched', mb_Ok);
- end;
-
- Constructor TMyWindow.Init(Aparent: PwindowsObject; ATitle: PChar);
- VAR
- ALong : MyLong;
- BEGIN
- TWindow.Init(Aparent, ATitle);
- Attr.Menu := LOadMenu(Hinstance, PChar(100));
- ALong.Lo := LoadBitmap(Hinstance, PChar(501));
- ModifyMenu(Attr.Menu, 101, mf_ByCommand or mf_Bitmap, 101,
- PChar(Along.TheLong));
- End;
-
-
- PROCEDURE TMyWindow.MakeBrush;
- {Copied from TPW Windows Programing Guide Pg 279}
- VAR
- MyLogBrush : TLogBrush;
- HMyBit : MyLong;
- BEGIN
- HMyBit.Lo := LoadBitmap(HInstance,'pryamid');
- MyLogBrush.lbStyle := bs_Pattern;
- MyLogBrush.lbHatch := HMyBit; {Type mismatch on this line}
- TheBrush := CreateBrushIndirect(@MyLogBrush);
- END;
-
-
- {--------------------------------------------------}
- { TMyApplication's method implementations: }
- {--------------------------------------------------}
-
- procedure TMyApplication.InitMainWindow;
- begin
- MainWindow := New(PMyWindow, Init(nil, 'Sample ObjectWindows Program'));
- end;
-
- {--------------------------------------------------}
- { Main program: }
- {--------------------------------------------------}
-
- var
- MyApp: TMyApplication;
-
- begin
- MyApp.Init('MyProgram');
- MyApp.Run;
- MyApp.Done;
- end.
-